﻿using System.Xml;

namespace Jayden.Dll.Core.Extensions
{
	public static class XmlElementExtensions
	{
		public static void OverrideAttributes(this XmlElement xmlElement, XmlElement overridingXml)
		{
			foreach (XmlAttribute attribute in overridingXml.Attributes)
			{
				XmlAttribute attributeToOverride = xmlElement.Attributes[attribute.Value];
				if (attributeToOverride == null)
				{
					attributeToOverride = xmlElement.OwnerDocument.CreateAttribute(attribute.Name);
					xmlElement.Attributes.Append(attributeToOverride);
				}
				attributeToOverride.Value = attribute.Value;
			}
		}
	}
}
